import { createApp, ref } from 'vue'
import Dialog from './index.vue'
const msg = ref(10)
const createDialog = (message, option = {}) => {
    const mountNode = document.createElement('div')
    const Instance = createApp(Dialog, {
        show: true,
        message,
        msg,
        ...option,
        onChange(){
            msg.value+=10
        },
        onClose: () => {
            Instance.unmount(mountNode);
            document.body.removeChild(mountNode);
        }
    })

    document.body.appendChild(mountNode)
    const vm = Instance.mount(mountNode)//vm是子组件实例
    return vm;
    // console.log(666, vm.handleClose())//调用子组件方法
}

export default createDialog